home *** CD-ROM | disk | FTP | other *** search
- Path: columba.udac.uu.se!not-for-mail
- From: trulsson@student.docs.uu.se (Erik Trulsson)
- Newsgroups: comp.lang.c
- Subject: Re: C/C++ cross-platform compatibility
- Date: 7 Mar 1996 17:52:23 GMT
- Organization: Uppsala Universitet
- Message-ID: <4hn7on$1ttc@columba.udac.uu.se>
- References: <4hfvlk$dn1@bay> <313BD1B0.40AB@ix.netcom.com>
- NNTP-Posting-Host: minsk.docs.uu.se
- X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
-
- Henry Cross (hcross@ix.netcom.com) wrote:
- > charrick@netrover.com wrote:
- > >
- > > I'm working on an application I want to compile on many
- > > different platforms. Somewhere along the line, I need to
- > > obtain a list of all files in a directory. In OS/2, DOS,
- > > WinNT, etc... the way to do this is with DosFindFirst and
- > > DosFindNext. However, these are not part of the ANSI
- > > standard, so I want to know, what should I use? Are these
- > > actually supported on everything, or is there another way
- > > to do this?
- >
- > I'm not a pro but I do believe this is an OS specific problem
- > that can't be solved by any current ANSI standard function.
- >
-
- This is indeed an OS-specific issue. There are no functions
- that are available on all , or even on most , platforms for getting
- the contents of a directory.
-
- The only way should be to write wrapper functions that are conditionally
- compiled to call the right function(s).
- I.e. something like:
-
- mygetdirlist(char *dirname)
- {
- #ifdef MSDOS
- DosFindFirst...
- ...
- #endif
-
- #ifdef UNIX
- opendir(...)
- readdir(...)
- ...
- #endif
-
- #ifdef AMIGA
- ....
- #endif
-
- }
-
- (The above certainly isn't correct code but the general idea should be clear)
-
- Some support for directory manipulation should really be in the C Standard.
- (At least on those platforms that even support the concept of directories.
- (The vast majoirty of them that is. ))
-
-